package com.googlecode.mvcguice.action;

import java.util.Collections;
import java.util.Map;

final class SingleAttrViewRenderAction implements ViewRenderAction {
	private static final String DEFAULT_NAME_SINGULAR = "instance";
	private static final String DEFAULT_NAME_PLURAL = "instances";

	private final Map<String, Object> attributes;

	SingleAttrViewRenderAction(String name, Object value) {
		attributes = Collections.singletonMap(name, value);
	}

	SingleAttrViewRenderAction(Object instance) {
		this(DEFAULT_NAME_SINGULAR, instance);
	}

	SingleAttrViewRenderAction(Iterable<?> instances) {
		this(DEFAULT_NAME_PLURAL, instances);
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}
}
